<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="inc/home::header">
</head>
<link type="text/css" th:href="@{/css/content.css}" rel="stylesheet" />
	<body>
		<div class="back"  onclick="loadPage('/Spare/out')"><img src="/images/back.png" /></div>
		<div th:include="header :: header"></div>
		<div class="header-title">
			<span>历史记录</span>
		</div>
		<div class="spare-a">
			<div class="questions-ar">
				<div class="spare-ara">
					<div class="spare-ara-a clearfix">
						<div class="spare-ara-al">
							<div class="spare-ara-all"><input type="text" placeholder="请输入名称"  name="spareName" id="spareName"/></div>
							<div class="spare-ara-alr" onclick="js_method()"></div>
						</div>
						<div class="spare-ara-ar">
							<a onclick="loadPage('/Spare/out-search','N')" class="spare-tj" >高级搜索</a>
						</div>
					</div>
					<div class="srcoll-documentation" id="srcoll-documentation">
					<div class="documentation paper">
					  <ul class="lists" id="lists">

					  </ul>
					</div>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script th:inline="javascript">
	/*<![CDATA[*/
	var Startime=[[${#httpServletRequest.getParameter('Startime')}]];
	var Endtime=[[${#httpServletRequest.getParameter('Endtime')}]];
	var createUser=[[${#httpServletRequest.getParameter('createUser')}]];
	var spareCode=[[${#httpServletRequest.getParameter('spareCode')}]];
	$(function() {
		if(Startime||Endtime||createUser||spareCode){
			$('#lists').html("");
			loadDataPage1("/Spare/SpareS/out-record", "srcoll-documentation", "lists", 12,Startime,Endtime,createUser,spareCode);
		}else{
			loadDataPage("/Spare/SpareM/out-record", "srcoll-documentation", "lists", 12,"spareName");
		}		
	});
	function js_method() {
		$(".dropload-down").remove();
		$('#lists').html("");
		loadDataPage("/Spare/SpareM/out-record", "srcoll-documentation", "lists", 12,"spareName");
	
	}
	function dataKk(data, me) {
		var result = '';
		var arrLen = data.length;
		if (arrLen > 0) {
			for (var i = 0; i < arrLen; i++) {
				result += '<a href="#">' + '<li id='+data[i].id+'>'
				+ '<div class="spare-new clearfix">'
				+ '<div class="spare-newl">编号/型号：' + data[i].spareCode+ '</div>' 
				+ '<div class="spare-newl">序列号：' + data[i].spareNo+ '</div>'
				+ '</div>'
				+ '<div class="spare-new clearfix">'
				+ '<div class="spare-newl">名称：' + data[i].spareName + '</div>' 
				+ '<div class="spare-newl">出库数量：' + data[i].spareQuantity + '</div>'
				+ '</div>'
				+ '<div class="spare-new clearfix">'			
				+ '<div class="spare-newl">供应商：' + data[i].spareSupplier+ '</div>'
				+ '<div class="spare-newl">类型：' + data[i].spareType+ '</div>'
				+ '</div>'
				+ '<div class="spare-new clearfix">'			
				+ '<div class="spare-newl">出库人员：' + data[i].createUser+ '</div>'
				+ '<div class="spare-newl">日期：' + data[i].createDate+ '</div>'
				+ '</div>'
				+ '<div class="documentation-check"></div>'
				+ '</li>' + '</a>'
			}
		} else {
			me.lock();
			me.noData();
		}
		return result;
	}
	
	function loadDataPage1(path, classId1, classId, pageSize, search, search2, search3, search4) {
	    // 页数
	    var page = 0;
	    // 每页展示
	    var size = pageSize;
	    var dropload = $('#' + classId1).dropload({
	        domDown: {
	            domClass: 'dropload-down',
	            domRefresh: '<div class="dropload-refresh"></div>',
	            domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
	            domNoData: '<div class="dropload-noData"></div>'
	        },
	        loadDownFn: function(me) {
	            page++;
	            $.ajax({
	                type: 'post',
	                url: path,
	                data: {
	                    pageNo: page,
	                    pageSize: size,
	                    search: search,
	                    search2: search2,
	                    search3: search3,
	                    search4: search4
	                },
	                dataType: 'json',
	                success: function(data) {
	                    var result = dataKk(data, me);
	                    $('#' + classId).append(result);
	                    window.oncontextmenu = function() {
	                        return false;
	                    }
	                    $(".documentation a").on('contextmenu',
	                    function() {
	                        // pad长按选中，pc右键选中
	                        $(this).children('li:eq(0)').addClass("active");
	                        $('.spare-ara-ar').find('a[hid="Y"]').show();
	                    }).click(function(e) {
	                        // pad单击选中状态取消选择，未选择状态跳转查看
	                        if ($(this).children('li:eq(0)').attr('class').indexOf('active') > -1) {
	                            $(this).children('li:eq(0)').removeClass("active");
	                            if ($('.spare-ara').find('li[class="active"]').length === 0) {
	                                $('.spare-ara-ar').find('a[hid="Y"]').hide();
	                            }
	                            e.preventDefault();
	                        }
	                    });
	                    // 全选，取消选择   	                    
	                    $('.spare-qx').off('click').on('click',
	                    function(e) {
	                    	
	                        if ($(this).attr('sel') == 'Y') {
	                            $(this).html('取 消').attr('sel', 'N');
	                            $('.documentation li').addClass('active');
	                        } else {
	                       
	                            $(this).html('全 选').attr('sel', 'Y');
	                            $('.documentation li').removeClass('active');
	                            $('.spare-ara-ar').find('a[hid="Y"]').toggle();
	                        }
	                        e.preventDefault();
	                    });
	              
	                    me.resetload();
	                }
	            });
	        }
	    });
	}
	/*]]>*/
</script>
</html>
